<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>有趣的css - 动态勾选多选框效果</title>
    <style>
      label {
        display: flex;
        align-items: center;
      }
      .check-inp {
        width: 20px;
        height: 20px;
        border: 2px solid #000000;
        border-radius: 5px;
        cursor: pointer;
        position: relative;
        transition: all 0.2s ease-in-out;
        appearance: none; /* none时可以自定义其外观 */
      }
      .check-inp:after {
        content: "";
        width: 12px;
        height: 12px;
        background-color: #0093e9;
        border-radius: 3px;
        position: absolute;
        top: 2px;
        left: 2px;
        transform: scale(0);
        transition: all 0.2s ease-in-out;
      }
      .check-inp:checked:after {
        transform: scale(1);
      }
      .check-inp:hover,
      .check-inp:checked {
        border-color: #0093e9;
      }
      .check-inp + span {
        height: 22px;
        line-height: 22px;
      }
    </style>
  </head>
  <body>
    <label class="label">
      <input type="checkbox" class="check-inp" />
      <span>足球</span>
    </label>
    <label class="label">
      <input type="checkbox" class="check-inp" />
      <span>篮球</span>
    </label>
  </body>
</html>
